package com.t11;

import java.util.PriorityQueue;

/**
 * Created by xuyiwei on 2018/7/22.
 */
class Dummy {}
public class E29_PriorityQueueSubtlety {
    public static void main(String[] args) {
        PriorityQueue<Dummy> priorityQueue =
                new PriorityQueue<Dummy>();
        System.out.println("Adding 1st instance...");
        priorityQueue.offer(new Dummy());
        System.out.println("Adding 2nd instance...");
        //会报错
        /**
         * DK文档指出:“依赖自然排序的优先队列也不允许插入非可比对象(这样做可能导致ClassCastException)。第二个插入将触发一个异常。
         */
        priorityQueue.offer(new Dummy());
    }
}
